home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / linuxcon.000 / linuxcon / linuxconf-1.6 / netconf / level.c < prev    next >
C/C++ Source or Header  |  1996-03-09  |  1KB  |  46 lines

  1. #include <stdio.h>
  2. #include "netconf.h"
  3. #include "../misc/misc.h"
  4. #include "netconf.m"
  5.  
  6. static NETCONF_HELP_FILE help_netlevel ("netlevel");
  7. static CONFIG_FILE f_netlevel (VAR_RUN_NETLEVEL,help_netlevel,CONFIGF_MANAGED);
  8. /*
  9.     Store the net level into /var/run/netconf.level
  10. */
  11. void netconf_setnetlevel(int level)
  12. {
  13.     FILE *fout = f_netlevel.fopen ("w");
  14.     if (fout != NULL){
  15.         fprintf (fout,"%d\n",level);
  16.         fclose (fout);
  17.     }
  18. }
  19.  
  20. /*
  21.     Retrieve the net level from /var/run/netconf.level
  22. */
  23. int netconf_getnetlevel()
  24. {
  25.     int level;
  26.     FILE *fin = f_netlevel.fopen ("r");
  27.     if (fin != NULL){
  28.         fscanf (fin,"%d\n",&level);
  29.         fclose (fin);
  30.     }
  31.     if (level < 0 || level > 2){
  32.         xconf_error (MSG_U(E_IVLDNETLEVEL
  33.             ,"File %s\n"
  34.              "contains an invalid netconf level: %d\n"
  35.              "It must be 0, 1 or 2.\n"
  36.              "Just run \"netconf --runlevel\" with an\n"
  37.              "explicit value (local, client, or server)\n"
  38.              "to fix this.\n"
  39.              "\n"
  40.              "Assuming \"local\" configuration for now.\n")
  41.             ,VAR_RUN_NETLEVEL,level);
  42.     }
  43.     return level;
  44. }
  45.  
  46.